package com.delivery.www.service.ServiceImpl;

import com.delivery.www.dao.StoreDao;
import com.delivery.www.dao.DaoImpl.StoreDaoImpl;
import com.delivery.www.po.Store;
import com.delivery.www.service.StoreService;
import com.delivery.www.util.JdbcUtils;

import java.sql.Connection;
import java.sql.SQLException;

public class StoreServiceImpl implements StoreService {
    private StoreDao storeDao;

    public StoreServiceImpl() {
        storeDao = new StoreDaoImpl();
    }

    @Override
    public boolean createStore(String name, String introduce, int id) {
        boolean flag = false;
        int store = storeDao.createStore(name, introduce, id, 0, 0, 0, 0);
        if (store > 0) {
            flag = true;
        }
        return flag;
    }

    @Override
    public Store getOwnStore(int id) {
        Store store = null;
        store = storeDao.getOwnStore(id);
        return store;
    }

    @Override
    public boolean updateStoreName(int stoerId, String value) {
        boolean flag = false;
        int i = storeDao.updateStoreName(stoerId, value);
        if (i > 0) {
            flag = true;
        }
        return flag;
    }

    @Override
    public boolean updateStoreIntroduce(int stoerId, String value) {
        boolean flag = false;
        int i = storeDao.updateStoreIntroduce(stoerId, value);
        if (i > 0) {
            flag = true;
        }
        return flag;
    }
}
